<?php
/**
 * Controller to manage product templates in admin area
 * 
 * @author Konstantin Shamko <konstantin.shamko@gmail.com> 
 * @version 0.0.1
 * @copyright  Copyright (c) 2009 Konstantin Shamko
 * @package Products Module
 * @license  New BSD License
 * 
 */
class admin_ProducttemplatesController extends Bel_Controller_Aed  {

	/**
	 * Initialization. Creates left menu for index & form action
	 * 
	 */		
	function init() {
		$this->_model = new Models_ProductTemplates();
		$this->_formname = 'product_templates_form';
		parent::init ();
		$this->_items_on_page = 25;
		if($this->_request->getParam('product_template_id') && $this->_request->getActionName()=='form'){
			Helpers_Products_Admin_TemplatesMenu::leftMenu($this->_request->getParam('product_template_id'));
		}
	}
	
	/**
	 * Change _index_action to _form_action value to redirect to form after modifying product.
	 * Usability feature 
	 *
	 */
	protected function _beforeModify(){
		$this->_index_action = $this->_form_action;
	}
	
	/**
	 * Celars products cache after template del.
	 *
	 */
	protected function _afterDelete(){
		Helpers_Products_Cache::cleanProductCacheByTemplate($this->_current_entry['template_id']);
	}
}